package conexion.util;

import java.io.Reader;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;


public class MysqlConfigUtil {  
    private static SqlSessionFactory sqlSessionFactory;
	//static Logger logger=Mgrlog4j.getClassLogger(MysqlConfigUtil.class.getName());
    private static final String config ="conexion/config/ConexionConfig.xml";

    static {

        try {
            Reader reader = Resources.getResourceAsReader(config);
             if (sqlSessionFactory == null) {  
                 sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
            }

        } catch (Exception e) {
            throw new RuntimeException(
                    "Could not initialize WorklistConfig.  Cause: " + e);
        }
        catch (Throwable e) {
        	throw new ExceptionInInitializerError(e);
        	}

    }

   public static SqlSessionFactory getSqlSessionFactory() {
        return sqlSessionFactory;
    }

}
